//
//  Collectioncell.m
//  SnackCourier
//
//  Created by qianfeng01 on 15/7/26.
//  Copyright (c) 2015年 qianfeng01. All rights reserved.
//

#import "Collectioncell.h"

@implementation Collectioncell

- (void)awakeFromNib {
    // Initialization code
}
-(void)showDataWithIndexPath:(NSIndexPath *)indexPath Array:(NSMutableArray *)array myblock:(CollerBlock)myblock{
    self.myblock=myblock;
    self.array=array;
    self.indexPath=indexPath;
    
    YJImmediatelygrabControllerModel *model =array[indexPath.row];
    [self.imgImageView sd_setImageWithURL:[NSURL URLWithString:model.imgUrl]];
    self.titleLabel.text= model.title;
    self.priceLabel.text =[NSString stringWithFormat:@"￥%@",model.price];
    if (model.originalPrice.length!=0) {
        self.originalPriceLabel.text =[NSString stringWithFormat:@"￥%@",model.originalPrice];
    }else{
        self.originalPriceLabel.text =@"";
    }
}


- (IBAction)deleteClick:(UIButton *)sender {
    YJImmediatelygrabControllerModel *model =self.array[self.indexPath.row];
    [[DBManager sharedManager] deleteModelForId:model.id];
    [self.array removeObject:self.array[self.indexPath.row]];
    if (self.myblock) {
        self.myblock(self.array);
    }
    
}
@end
